<?php /*
Create this table as output. Find the logic behind this and give the output.
*/
error_reporting(0); 
?>
<form action="ex1.php" method="post">
<input type="text" name="firstnumber" value="<?php echo $_POST['firstnumber'];?>"/>
<input type="text" name="secondnumber" value="<?php echo $_POST['secondnumber'];?>"/><br><br>
<input type="radio" name="mul" value="muli" />Multiplication<br>
<input type="radio" name="mul" value="add" />Addition<br>
<input type="radio" name="mul" value="mod" />Module<br>
<input type="submit" name="check" value="calculate" />
</form>
<table border="1" cellspacing="0"> 
<?php
//print_r($_POST);
if(isset($_POST['check']))
	{
	  $a  = $_POST['firstnumber'];
	  $b  = $_POST['secondnumber'];
	  for($i=1; $i<=$a; $i++)
	  { ?><tr><?php
		  for($j=1; $j<=$b; $j++)
		  {
			  $mul = $i*$j;
			  $add = $i+$j;
			  $mod = $i%$j;
		         
				if(isset($_POST['mul']) && $_POST['mul']=='muli')
				{?>
			     <td style="padding-right:50px;"><?php 		
				 echo $mul .'<br>';?>
			     </td><?php
				}  
				if(isset($_POST['mul'])&& $_POST['mul']=='add')
				{	?>
			      <td style="padding-right:50px;"><?php 		  
				  echo $add .'<br>';?>
			      </td><?php
				  
				}
				if(isset($_POST['mul'])&& $_POST['mul']=='mod')
				{ ?>
			      <td style="padding-right:50px;"><?php 
				  echo $mod .'<br>';?>
			     </td><?php
				}
		  }
		  ?></tr><?php
	  }
	}
?>
</table>

